
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <title>根据地址查询</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
    <script src="../plugins/healthmobile.js"></script>
    <script>
        var value = getUrlParam("value");
        var value =decodeURI(getUrlParam("value"));


    </script>
</head>
<style>
    body{
        background:#CBE1FF;margin:0;padding:0;
    }
    .con{
        height: 70px;
        width: 480px;
    }
    .btn{
        height: 70px;
        width: 100px
    }
    *{
        font-size: 30px
    }
    #container{
        position: absolute;margin-top:10px;
        width: 100%;
        height: 84%;top:50px;left:0;border: 1px solid gray;overflow:hidden;
    }
    #ok{
        display: inline-block;
        background: #F1F1F1;
        text-align: center;
        line-height:70px;
        border: 1px solid #A9A9A9;
        text-decoration: none;
        color: black;
    }
    #find{
        margin-left:8px;

    }
</style>

<body>
<br>
<div><input onClick="javascript:history.back();" type="button"  value="返回"/></div>

<div style="display:none">&emsp; &emsp;

    <input id="text_" class="con" placeholder="" type="text" value="" hidden/>&emsp;
    <input type="button" class="btn" id="find" value="" onclick="searchByStationName();" hidden/>  &emsp;
    <br>
    <br>

    <input id="result_" class="con"  type="text"  hidden/>  &emsp;

</div>
<div id="container" style="margin-top: 100px">

</div>



</body>
<script type="text/javascript">

    document.getElementById("text_").value=value;
    sessionStorage.setItem("need-refresh", true);
    // 模拟点击
    setTimeout(function() {
        // IE
        if(document.all) {
            document.getElementById("find").click();
        }
        // 其它浏览器
        else {
            var e = document.createEvent("MouseEvents");
            e.initEvent("click", true, true);
            document.getElementById("find").dispatchEvent(e);
        }
    });


    function loadJScript() {
        var script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = '//api.map.baidu.com/api?type=webgl&v=1.0&ak=7PGGYAkt1oBWqEIMZeyimzBbpY57MqcV&callback=init';
        document.body.appendChild(script);
    }
    var map = new BMap.Map("container");
    map.centerAndZoom("北京", 15);
    map.enableScrollWheelZoom(); //启用滚轮放大缩小，默认禁用
    map.enableContinuousZoom(); //启用地图惯性拖拽，默认禁用

    map.addControl(new BMap.NavigationControl()); //添加默认缩放平移控件
    map.addControl(new BMap.OverviewMapControl()); //添加默认缩略地图控件
    map.addControl(new BMap.OverviewMapControl({
        isOpen: true,
        anchor: BMAP_ANCHOR_BOTTOM_RIGHT
    })); //右下角，打开
    window.onload = loadJScript;
    var localSearch = new BMap.LocalSearch(map);
    function searchByStationName() {
        map.clearOverlays(); //清空原来的标注
        var keyword = document.getElementById("text_").value;
        localSearch.setSearchCompleteCallback(function(searchResult) {
            var poi = searchResult.getPoi(0);
            document.getElementById("result_").value = poi.point.lng + "," + poi.point.lat;
            map.centerAndZoom(poi.point, 13);
            var marker = new BMap.Marker(new BMap.Point(poi.point.lng, poi.point.lat)); // 创建标注，为要查询的地方对应的经纬度
            map.addOverlay(marker);
            var content = document.getElementById("text_").value + "<br/><br/>经度：" + poi.point.lng + "<br/>纬度：" + poi.point.lat;

            var infoWindow = new BMap.InfoWindow("<p style='font-size:14px;'>" + content + "</p>");
            marker.addEventListener("click", function() {
                this.openInfoWindow(infoWindow);
            });
            // marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
        });
        localSearch.search(keyword);
    }

</script>
</html>